9.1 Bootconfig File
During the boot process, Linux can configure kernel parameters via the cmdline string. The cmdline originates from the tag structures passed by U-Boot to the kernel boot procedure. It is a text string containing multiple configuration options, such as console and video. Among these options, variables containing the = delimiter are utilized to configure environment variables for the init() process, whereas variables lacking the = delimiter represent command-line variables passed to the init() process, and variables succeeding the -- marker are explicitly forwarded to the init() process.
If the cmdline string contains the keyword "bootconfig", it denotes that the Linux system supplies supplemental kernel parameters via a bootconfig file. The bootconfig file is appended immediately to the end of the initrd image, as illustrated in the figure below:
Figure 9-1 Storage Location of the Bootconfig File
The bootconfig file is an ASCII text file placed directly adjacent to the initrd. Succeeding the bootconfig file is its total size in bytes, followed by the size of the checksum block and the checksum value itself, each occupying 4 bytes. Finally, a 12-byte magic string "#BOOTCONFIG\n" concludes the block to serve as the signature identifier for the bootconfig file.
The structural syntax for each entry within a bootconfig file is formatted as: KEY[.WORD[...]] = VALUE[, VALUE2[...]][;]. The keyword (KEY) denotes the variable intended for configuration, such as video or console. A WORD is also designated as a subkey, which is utilized to further compartmentalize a keyword. Keywords must only consist of alphanumeric characters, hyphens (-), or underscores (_). The parameter assignment (VALUE) must consist solely of printable characters or spaces, excluding delimiters such as ,, ;, newlines, #, and }. To incorporate these explicit delimiters within a value assignment, the value must be encapsulated within single ('') or double ("") quotation marks. When writing the file, entries sharing identical subkey path segments can be grouped together. For instance, the variable foo.bar.baz and the variable foo.bar.qux.quux can either be expressed as:
foo.bar.baz = value1
foo.bar.qux.quux = value2
or grouped and expressed as:
foo.bar {
baz = value1
qux.quux = value2
}
or:
foo.bar { baz = value1; qux.quux = value2 }
In this context, foo acts as the parent key for bar, while bar represents the subkey of foo. Similarly, foo.bar acts as the parent key path for baz and qux.quux.
The grammatical rules of the bootconfig file dictate that the exact same keyword cannot be repeatedly assigned distinct values. Concurrently, a single keyword cannot simultaneously possess both a direct value assignment and child subkeys. Consequently, the following two scenarios:
foo = bar, baz
foo = qux
or
foo = value1
foo.bar = value2
are strictly forbidden.
The first scenario attempts duplicate assignments to the variable foo, while the second scenario configures foo to simultaneously possess the direct value value1 and the child subkey bar.
The bootconfig specification permits appending supplemental values to an existing variable via the += operator, as shown below:
foo = bar, baz
foo += qux